<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>主分片和副本分片如何交互 | Elasticsearch: 权威指南 | Elastic</title>
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
</head>
<body>
<div class="main-container">
    <section id="content">
        
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原文地址: <a href="https://www.elastic.co/guide/cn/elasticsearch/guide/current/how-primary-and-replica-shards-interact.html" rel="nofollow">https://www.elastic.co/guide/cn/elasticsearch/guide/current/how-primary-and-replica-shards-interact.html</a>, 版权归 www.elastic.co 所有<br/>
                            英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/how-primary-and-replica-shards-interact.html" rel="nofollow">https://www.elastic.co/guide/en/elasticsearch/guide/current/how-primary-and-replica-shards-interact.html</a>
                            </div>
                        <!-- start body -->
                  <div class="page_header">
<b>请注意:</b><br>本书基于 Elasticsearch 2.x 版本，有些内容可能已经过时。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch: 权威指南</a></span>
»
<span class="breadcrumb-link"><a href="getting-started.html">基础入门</a></span>
»
<span class="breadcrumb-link"><a href="distributed-docs.html">分布式文档存储</a></span>
»
<span class="breadcrumb-node">主分片和副本分片如何交互</span>
</div>
<div class="navheader">
<span class="prev">
<a href="routing-value.html">« 路由一个文档到一个分片中</a>
</span>
<span class="next">
<a href="distrib-write.html">新建、索引和删除文档 »</a>
</span>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="how-primary-and-replica-shards-interact"></a>主分片和副本分片如何交互<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elasticsearch-cn/elasticsearch-definitive-guide/edit/cn/040_Distributed_CRUD/10_Shard_interaction.asciidoc">edit</a>
</h2>
</div></div></div>
<p>为了说明目的, 我们 假设有一个集群由三个节点组成。
它包含一个叫 <code class="literal">blogs</code> 的索引，有两个主分片，每个主分片有两个副本分片。相同分片的副本不会放在同一节点，所以我们的集群看起来像 <a class="xref" href="how-primary-and-replica-shards-interact.html#img-distrib" title="有三个节点和一个索引的集群">Figure 8, “有三个节点和一个索引的集群”</a>。</p>
<div id="img-distrib" class="imageblock">
<div class="content">
<img src="../images/elas_0401.png" alt="有三个节点和一个索引的集群">
</div>
<div class="title">Figure 8. 有三个节点和一个索引的集群</div>
</div>
<p>我们可以发送请求到集群中的任一节点。 每个节点都有能力处理任意请求。
每个节点都知道集群中任一文档位置，所以可以直接将请求转发到需要的节点上。
在下面的例子中，将所有的请求发送到 <code class="literal">Node 1</code> ，我们将其称为 <em>协调节点(coordinating node)</em> 。</p>
<div class="tip admon">
<div class="icon"></div>
<div class="admon_content">
<p>当发送请求的时候， 为了扩展负载，更好的做法是轮询集群中所有的节点。</p>
</div>
</div>
</div>
<div class="navfooter">
<span class="prev">
<a href="routing-value.html">« 路由一个文档到一个分片中</a>
</span>
<span class="next">
<a href="distrib-write.html">新建、索引和删除文档 »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>